#[cfg(test)]
#[allow(unused)]
mod tests {
    use glass_core::{
        error::ConvertError,
        reflect::Reflect,
        ty::{Field, FieldSerde, Fields, Members, Object, TypeInfo, TypeKind, Value},
    };
    use std::{any::type_name, collections::HashMap};

    #[test]
    fn it_works() {
        pub struct Student {
            pub name: String,
            pub age: i32,
        }

        impl TryFrom<Value> for Student {
            type Error = ConvertError;

            fn try_from(value: Value) -> Result<Self, Self::Error> {
                if let Value::Enum(variant, value) = value {
                    let value = *value;
                    match variant.as_str() {
                        "Some" => {
                            if let Value::NamedStruct(mut values) = value {
                                return Ok(Student {
                                    name: values
                                        .remove("name")
                                        .ok_or(ConvertError::missing_field("name"))?
                                        .try_into()?,
                                    age: values
                                        .remove("age")
                                        .ok_or(ConvertError::missing_field("age"))?
                                        .try_into()?,
                                });
                            }
                            Err(ConvertError::TypeMismatch {
                                expected: String::from("NamedStruct"),
                                actual: value.to_string(),
                            })
                        }
                        _ => Err(ConvertError::TypeMismatch {
                            expected: String::from("Some"),
                            actual: variant,
                        }),
                    }
                } else {
                    Err(ConvertError::TypeMismatch {
                        expected: String::from("Enum"),
                        actual: value.to_string(),
                    })
                }
            }
        }

        impl TryInto<Object> for Student {
            type Error = ConvertError;

            fn try_into(self) -> Result<Object, Self::Error> {
                let mut values = HashMap::new();
                values.insert(
                    "name".to_string(),
                    <String as TryInto<Object>>::try_into(self.name)?.value,
                );
                values.insert(
                    "age".into(),
                    <i32 as TryInto<Object>>::try_into(self.age)?.value,
                );
                let mut object = Object {
                    type_info_fn: Self::type_info,
                    value: Value::Enum("".into(), Box::new(Value::NamedStruct(values))),
                };
                Ok(object)
            }
        }

        impl Reflect for Student {
            fn members() -> Members {
                Members::Fields(Fields {
                    fields: vec![
                        Field {
                            docs: None,
                            index: 0,
                            ident: Some("name".to_string()),
                            type_info_fn: <String as Reflect>::type_info,
                            attrs: vec![],
                            constraits: vec![],
                            serde: FieldSerde::default(),
                            name: None,
                        },
                        Field {
                            docs: None,
                            index: 1,
                            ident: Some("age".to_string()),
                            type_info_fn: <i32 as Reflect>::type_info,
                            attrs: vec![],
                            constraits: vec![],
                            serde: FieldSerde::default(),
                            name: None,
                        },
                    ],
                    named: false,
                })
            }
        }

        fn print_type_info<T: Reflect>() {
            let ty_info = T::type_info();
            match ty_info.members {
                Members::Fields(fields) => {
                    println!("{fields:?}");
                }
                Members::Variants(variants) => {
                    println!("{variants:?}");
                }
            }
        }
        print_type_info::<Student>();
    }
}
